package com.project.personalfundmanager.shared.models;

import javax.persistence.Id;

import com.extjs.gxt.ui.client.data.BaseModel;
import com.google.gwt.user.client.rpc.IsSerializable;
import com.project.personalfundmanager.shared.DAOs.TaxInfoGroupDAO;

public class TaxInfoGroupModel extends BaseModel implements IsSerializable
{
	private static final long serialVersionUID = 1L;
	@Id
	Long uid;
	TaxableIncomeModel taxIncome;
	Section10Model sec10Model;
	Section24Model sec24Model;
	Section80CModel sec80CModel;
	SectionOthersModel secOthersModel;
	PayableTaxModel payableTaxModel;

	public TaxInfoGroupModel( TaxInfoGroupDAO dao )
	{
		set( "uid", dao.getUid() );
		set( "taxableIncome", new TaxableIncomeModel( dao.getTaxIncome() ) );
		set( "section10Model", new Section10Model( dao.getSec10DAO() ) );
		set( "section24Model", new Section24Model( dao.getSec24DAO() ) );
		set( "section80CModel", new Section80CModel( dao.getSec80CDAO() ) );
		set( "sectionOthersModel", new SectionOthersModel( dao.getSecOthersDAO() ) );
		set( "payableTaxModel", new PayableTaxModel( dao.getPayableTaxDAO() ) );
	}

	public TaxInfoGroupModel()
	{
		set( "uid", 0 );
		set( "taxableIncome", new TaxableIncomeModel() );
		set( "section10Model", new Section10Model() );
		set( "section24Model", new Section24Model() );
		set( "section80CModel", new Section80CModel() );
		set( "sectionOthersModel", new SectionOthersModel() );
		set( "payableTaxModel", new PayableTaxModel() );
	}
	
	public static void copyToModel(TaxInfoGroupModel fromModel, TaxInfoGroupModel toModel)
	{
		TaxableIncomeModel.copyToModel( fromModel.getTaxableIncome(), toModel.getTaxableIncome() );
		Section10Model.copyToModel( fromModel.getSection10Model(), toModel.getSection10Model() );
		Section24Model.copyToModel( fromModel.getSection24Model(), toModel.getSection24Model() );
		Section80CModel.copyToModel( fromModel.getSection80CModel(), toModel.getSection80CModel() );
		SectionOthersModel.copyToModel( fromModel.getSectionOthersModel(), toModel.getSectionOthersModel() );
		PayableTaxModel.copyToModel( fromModel.getTaxCalculationModel(), toModel.getTaxCalculationModel() );
	}

	public TaxableIncomeModel getTaxableIncome()
	{
		return get( "taxableIncome" );
	}

	public Section10Model getSection10Model()
	{
		return get( "section10Model" );
	}

	public Section24Model getSection24Model()
	{
		return get( "section24Model" );
	}

	public Section80CModel getSection80CModel()
	{
		return get( "section80CModel" );
	}

	public SectionOthersModel getSectionOthersModel()
	{
		return get( "sectionOthersModel" );
	}

	public PayableTaxModel getTaxCalculationModel()
	{
		return get( "payableTaxModel" );
	}

	public void setUid( long id )
	{
		set( "uid", id );
	}

	public Long getUid()
	{
		return get( "uid" );
	}
}
